package com.jsgt.greekfire.ui.coin.adapter

import android.content.Context
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.jsgt.greekfire.R
import com.jsgt.greekfire.ui.coin.CoinsOrderBean
import com.jsgt.greekfire.ui.coin.ordermanagement.HistoricalOrdersBean

class CoinsOrderAdapter(
    context: Context,
    layoutId: Int,
    data: MutableList<CoinsOrderBean>? = null
) : BaseQuickAdapter<CoinsOrderBean, BaseViewHolder>(layoutId, data) {
    override fun convert(helper: BaseViewHolder, item: CoinsOrderBean) {
        helper.setText(R.id.tvCurrency, item?.currency)
            .setText(R.id.tvCurrency1, "/ETH")
            .setText(R.id.tvTime, item?.time)
            .setText(
                R.id.tvPrice,
                context.resources.getString(R.string.coins_orde_price) + "  " + item?.price
            )
            .setText(
                R.id.tvNum,
                context.resources.getString(R.string.coins_orde_num) + "  " + item?.num
            )
            .setText(R.id.tvTotal, item?.total)
            .setText(R.id.tvCny, "CNY")
            .setText(R.id.tvStatus, item?.status)
        if (item?.status.equals("未完成")) {
            helper.setTextColor(R.id.tvStatus, context.resources.getColor(R.color.white))
        } else if (item?.status.equals("已完成")) {
            helper.setTextColor(R.id.tvStatus, context.resources.getColor(R.color.white))
        } else if (item?.status.equals("已取消")) {
            helper.setTextColor(R.id.tvStatus, context.resources.getColor(R.color.color_F0724A))
        }

        if (item?.type.equals("1")) {
            helper.setBackgroundResource(R.id.tvType, R.drawable.buy_shape)
            helper.setText(R.id.tvType, "买")
        } else {
            helper.setBackgroundResource(R.id.tvType, R.drawable.sell_shape)
            helper.setText(R.id.tvType, "卖")
        }
    }
}
